package code.example.base.collection.queue;

import com.google.common.base.Objects;

public class Person  implements Comparable{
    String name;
    long money;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getMoney() {
        return money;
    }

    public void setMoney(long money) {
        this.money = money;
    }

    @Override
    public int compareTo(Object o) {
        if(o ==null || !Person.class.isInstance(o)){
            return 1;
        }else {
            Person p1 = (Person)o;
            long v = this.money -p1.money;
            if(v <0){
                return -1;
            }else if(v>0){
                return 1;
            }else {
                return 0;
            }
        }

    }

    @Override
    public String toString() {
        return Objects.toStringHelper(this)
                .add("name", name)
                .add("money", money)
                .toString();
    }
}
